from django.shortcuts import render
from rest_framework.viewsets import GenericViewSet
from buyHigh.utils.buyHighResponse import APIResponse
from .models import banner
from rest_framework.decorators import action
from .serializer import BannerSerializer
# Create your views here.
class BannerView(GenericViewSet):
    @action(methods=['get'],detail=False)
    def get_banner_list(self,request):
        # 从数据库中获取轮播图数据
        banner_list=banner.objects.all()[:3]
        ser=BannerSerializer(banner_list,many=True)
        return APIResponse(code=200,msg="获取轮播图成功",data=ser.data,statusCode=200)
